package com.qxsx.midi.activity.home;

import android.content.Intent;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.qxsx.midi.R;
import com.qxsx.midi.activity.base.BaseActivity;

/**
 * Created by Joney on 2015/9/29.
 * 轮播图详情
 */
public class AdvertisementActivity extends BaseActivity implements OnClickListener {

    private WebSettings mWebSettings;
    private WebView wv_myWebView;
    private String _url;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_advertisement);
        Intent intent = getIntent();
        _url = intent.getStringExtra("_url");
        Log.e("网页", _url);

        setTitle("");
        setNavBtn(R.mipmap.back, 0);
        findById();
        inItData();
    }

    private void inItData() {
        //支持javascript
        wv_myWebView.getSettings().setJavaScriptEnabled(true);
        // 设置可以支持缩放
        wv_myWebView.getSettings().setSupportZoom(true);
        // 设置出现缩放工具
        wv_myWebView.getSettings().setBuiltInZoomControls(true);
        //扩大比例的缩放
        wv_myWebView.getSettings().setUseWideViewPort(true);
        //自适应屏幕
        wv_myWebView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        wv_myWebView.getSettings().setLoadWithOverviewMode(true);
        wv_myWebView.getSettings().setTextSize(WebSettings.TextSize.LARGEST);
        wv_myWebView.loadUrl(_url);


    }

    private void findById() {
        wv_myWebView = (WebView) findViewById(R.id.wv_myWebView);

    }

    @Override
    protected void HandleTitleBarEvent(TitleBar component, View v) {


        switch (component) {

            case LEFT:
                finish();
                break;

        }
    }

    private class Callback extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return (false);
        }
    }

    @Override
    public void onClick(View v) {

    }
}
